package at.fhj.itm11.forum.service;

import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import at.fhj.itm11.forum.model.Topic;

// The @Stateless annotation eliminates the need for manual transaction demarcation
@Stateless
public class TopicRegistration {

   @Inject
   private EntityManager em;

   @Inject
   private Event<Topic> topicEventSrc;

   public void register(Topic topic) throws Exception {
      em.persist(topic);
      topicEventSrc.fire(topic);
   }
}
